home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / perl5000.zip / perl5000 / writemain.SH < prev    next >
Text File  |  1994-10-17  |  3KB  |  95 lines

  1. case $CONFIG in
  2. '')
  3.     if test -f config.sh; then TOP=.;
  4.     elif test -f ../config.sh; then TOP=..;
  5.     elif test -f ../../config.sh; then TOP=../..;
  6.     elif test -f ../../../config.sh; then TOP=../../..;
  7.     elif test -f ../../../../config.sh; then TOP=../../../..;
  8.     else
  9.         echo "Can't find config.sh."; exit 1
  10.     fi
  11.     . $TOP/config.sh
  12.     ;;
  13. esac
  14. : This forces SH files to create target in same directory as SH file.
  15. : This is so that make depend always knows where to find SH derivatives.
  16. case "$0" in
  17. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  18. esac
  19. echo "Extracting writemain (with variable substitutions)"
  20. : This section of the file will have variable substitutions done on it.
  21. : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
  22. : Protect any dollar signs and backticks that you do not want interpreted
  23. : by putting a backslash in front.  You may delete these comments.
  24. $spitshell >writemain <<!GROK!THIS!
  25. $startsh
  26. !GROK!THIS!
  27.  
  28. : In the following dollars and backticks do not need the extra backslash.
  29. $spitshell >>writemain <<'!NO!SUBS!'
  30. # This script takes the plain miniperlmain.c and writes out perlmain.c
  31. # which includes all the extensions.
  32. # The command line arguments name extensions to be used.
  33. #  E.g.:  sh writemain SDBM_File POSIX > perlmain.c
  34. #
  35.  
  36. orig="$*"
  37. args=''
  38. : Remove any .a suffixes and any leading path components
  39. for file in `echo $orig | sed 's/\.a//g'` ; do
  40.     case "$file" in
  41.     ext/*)    file=`echo $file | sed 's:ext/\(.*\)/[^/]*:\1:'`
  42.         ;;
  43.     */*)
  44.         file=`expr X$file : 'X.*/\(.*\)'`
  45.         ;;
  46.     esac
  47.     args="$args $file"
  48. done
  49.  
  50.  
  51. sed '/Do not delete this line--writemain depends on it/q' miniperlmain.c
  52. if test X"$args" != "X" ; then
  53.     echo "    char *file = __FILE__;"
  54.     ai=''
  55.  
  56.     for ext in $args ; do
  57.  
  58.     : $ext will either be 'Name' or 'Name1/Name2' etc
  59.     : convert ext into cname and mname
  60.     mname=`echo $ext   | sed 's!/!::!g'`
  61.     cname=`echo $mname | sed 's!:!_!g'`
  62.  
  63.     echo "    {   extern void boot_${cname} _((CV* cv));"
  64.     if test "$ext" = "DynaLoader"; then
  65.         : Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  66.         : boot_DynaLoader is called directly in DynaLoader.pm
  67.         echo "        newXS(\"${mname}::boot_${ext}\", boot_${cname}, file);"
  68.     else
  69.         echo "        newXS(\"${mname}::bootstrap\", boot_${cname}, file);"
  70.     fi
  71.     # does this extension wish to supply automatic booting code?
  72.     for aifile in ext/$ext/AutoInit.* ; do
  73.         case $aifile in
  74.         *.c)echo "    /* autoinit code from $aifile follows: */"
  75.             echo "    {"; cat $aifile; echo "    }"
  76.             ;;
  77.         *.pl) ai="$ai `cat $aifile | tr '\012' ' '`;"
  78.             ;;
  79.         esac
  80.     done
  81.     echo "    }"
  82.     done
  83.     if test "X$ai" != "X"; then
  84.     echo "    autoboot_preamble = \"BEGIN { $ai }\";"
  85.     fi
  86. fi
  87.  
  88. cat << 'EOP'
  89. }
  90. EOP
  91.  
  92. !NO!SUBS!
  93. chmod 755 writemain
  94. $eunicefix writemain
  95.